package com.cn.controller;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.PostConstruct;
import java.util.Timer;
import java.util.TimerTask;

@Controller
@RequestMapping("log")
public class LoggerLevelController {

  private final static Logger logger = LoggerFactory.getLogger(LoggerLevelController.class);

  public static void main(String[] args) {
    logger.info("main");
  }

  @PostConstruct
  public void run() {
    Timer timer = new Timer();
    timer.schedule(new TimerTask() {
      @Override
      public void run() {
        logger.debug("timer print debug...");
        logger.info("timer print info...");
        logger.warn("timer print warn...");
      }
    }, 5000, 10000);
  }

  @RequestMapping("/do")
  @ResponseBody
  public void loggerinfo() {
    logger.debug("print debug...");
    logger.info("print info...");
    logger.warn("print warn...");
  }


}
